package com.jiyun.service.init;

import com.jiyun.service.goods.AdService;
import com.jiyun.service.goods.CategoryService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component// </bean>标签，将对象注入到Spring中
public class Init implements InitializingBean {

    @Autowired
    CategoryService categoryService;

    @Autowired
    AdService adService;
    @Override
    // 在配置文件加载之后执行的代码
    public void afterPropertiesSet() throws Exception {
        // 完成了商品分类缓存预热
        categoryService.saveCategoryTreeToRedis();
        // 完成轮播图的缓存预热
        adService.saveAdToRedisByPosition("web_index_lb");
    }
}
